package com.iRomantic.domain.entity;

import java.sql.Timestamp;
import java.util.List;
import java.util.UUID;

import com.iRomantic.config.Constant;
import com.jfinal.plugin.activerecord.Model;

/**
 * 视频
 * @author serenity
 *
 */
public class Video extends Model<Video>{

	private static final long serialVersionUID = -7335262140499672422L;
	
	public static final Video DAO = new Video();
	
	/**
	 * 保存视频信息
	 */
	public boolean save(){
		if(this.getStr("id") == null)
		this.set("id", UUID.randomUUID().toString());
		this.set("createTime", new Timestamp(System.currentTimeMillis()));
		return super.save();
	}
	
	/**
	 * 设置资源全路径
	 * @param list
	 */
	public void setOSSPath(List<Video> list){
		for(Video p : list){
			p.set("url", Constant.OSS_PATH+Constant.VIDEO_PICTURE+ p.getStr("weddingId")+"/" +p.get("url"));
			p.set("thumbnailUrl", Constant.OSS_PATH+Constant.VIDEO_PICTURE +p.getStr("weddingId")+"/" +p.get("thumbnailUrl"));
		}
	}

}
